//
//  JYOrderInfoCell.m
//  JYFarm
//
//  Created by 花花 on 2017/10/17.
//  Copyright © 2017年 花花. All rights reserved.
//

#import "JYOrderInfoCell.h"

@implementation JYOrderInfoCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end



@interface JYOrderDetaView()<UITableViewDelegate,UITableViewDataSource>

@end
static NSString *const JYOrderInfoCellID = @"JYOrderInfoCellID";
@implementation JYOrderDetaView



- (void)setDataArr:(NSArray *)dataArr{

    _dataArr = dataArr;
    [self.orderTableView reloadData];
    

}
- (UITableView *)orderTableView{
    
    if (!_orderTableView) {
        
        _orderTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, Screen_Width, 270+90) style:UITableViewStylePlain];
        
        self.orderTableView.delegate =self;
        self.orderTableView.dataSource =self;
        self.orderTableView.bounces = NO;
        self.orderTableView.showsVerticalScrollIndicator = NO;
        [self.orderTableView registerNib:[UINib nibWithNibName:@"JYOrderInfoCell" bundle:nil] forCellReuseIdentifier:JYOrderInfoCellID];
        [self addSubview:self.orderTableView];
        
    }
    return _orderTableView;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.dataArr.count;


}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
 
    UILabel *label = [UILabel labelText:@"  订单号：666888123" fontSize:13 textColor:k3Color textAlignment:NSTextAlignmentLeft];
    label.backgroundColor = [UIColor whiteColor];
    label.frame = CGRectMake(10, 0, Screen_Width, 45);
    NSLog(@"_isCommitOrder:%zd",_isCommitOrder);
    if (_isCommitOrder ==YES) {
        NSLog(@"_____________");
        label.text =@"  订单商品";
        label.font = [UIFont boldSystemFontOfSize:17];
        
    }else{
        label.text = @"  订单号：666888123";
    
    }
    return label;

}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *footerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, Screen_Width, 45)];
    footerView.backgroundColor = [UIColor whiteColor];
    UILabel *leftlabel = [UILabel labelText:@"配送时间：9月26日 07：00-08：00" fontSize:13 textColor:k9Color textAlignment:NSTextAlignmentLeft];
    leftlabel.frame = CGRectMake(10, (footerView.height -20)/2, Screen_Width-2*10-120, 20);

    UILabel *rightLabel = [UILabel labelText:@"商品数量：30份" fontSize:13 textColor:k3Color textAlignment:NSTextAlignmentRight];
    rightLabel.frame = CGRectMake(Screen_Width-140, (footerView.height -20)/2, 120, 20);
    [footerView addSubview:leftlabel];
    [footerView addSubview:rightLabel];
    return footerView;

}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 45;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 45;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

        JYOrderInfoCell  *cell = [tableView dequeueReusableCellWithIdentifier:JYOrderInfoCellID];
        cell.nameLabel.text = @"有机空心心心菜有机空心心心菜";
        cell.imgView.image = [UIImage imageNamed:@"home_icon_wine"];
    
    
//    UILabel *label = [[UILabel alloc]init];
//    label.textColor = [UIColor colorWithHexString:@"EF216B"];
//    label.text  =  [NSString stringWithFormat:@"￥%zd.00",arc4random_uniform(100)];
////    momey.
//    //@"￥10.00";
//    //    NSString *yjStr = @"（含押金￥50元）";
//    NSString *yjStr =  [NSString stringWithFormat:@"%zd／个",arc4random_uniform(99)];
//    
//    ;
//    NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc]initWithString:label.text ];
//    NSDictionary *attributes = @{
//                                 NSFontAttributeName:kFont(13),
//                                 NSForegroundColorAttributeName:k9Color
//                                 };
//    NSAttributedString *str = [[NSAttributedString alloc]initWithString:yjStr attributes:attributes];
//    [attributedStr appendAttributedString:str];
//    cell.priceLabel.attributedText = attributedStr;
    cell.countLabel.text = [NSString stringWithFormat:@"x %zd份",arc4random_uniform(30)];
    
        cell.priceLabel.text = [NSString stringWithFormat:@"￥%zd.00",arc4random_uniform(150)];
    
        return cell;

}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    return 90;
  
    
}


@end
